<?php $show_header = $show_validator = $show_scroll = 1; include $this->admin_tpl('header', 'attachment');?>
<link href="<?php echo JS_PATH?>swfupload/swfupload.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript" src="<?php echo JS_PATH?>swfupload/swfupload.js"></script>
<script language="JavaScript" type="text/javascript" src="<?php echo JS_PATH?>swfupload/fileprogress.js"></script>
<script language="JavaScript" type="text/javascript" src="<?php echo JS_PATH?>swfupload/handlers.js"></script>
<script type="text/javascript">
    <?php echo initupload($_GET['module'],$_GET['catid'],$args,$this->userid,$this->groupid,$this->isadmin,$userid_flash)?>
</script>
<div class="pad-10">
    <div class="col-tab">
        <ul class="tabBut cu-li">
            <li id="tab_swf_1" <?php echo $tab_status?> onclick="SwapTab('swf','on','',5,1);"><?php echo L('upload_attachment')?></li>
            <li id="tab_swf_2" onclick="SwapTab('swf','on','',5,2);"><?php echo L('net_file')?></li>
            <?php if($allowupload && $this->admin_username && $_SESSION['userid']) {?>
                <li id="tab_swf_3" onclick="SwapTab('swf','on','',5,3);set_iframe('album_list','index.php?m=attachment&c=attachments&a=album_load&args=<?php echo $args?>');"><?php echo L('gallery')?></li>
                <li id="tab_swf_4" onclick="SwapTab('swf','on','',5,4);set_iframe('album_dir','index.php?m=attachment&c=attachments&a=album_dir&args=<?php echo $args?>');"><?php echo L('directory_browse')?></li>
            <?php }?>
            <?php if($att_not_used!='') {?>
                <li id="tab_swf_5" class="on icon" onclick="SwapTab('swf','on','',5,5);"><?php echo L('att_not_used')?></li>
            <?php }?>
        </ul>
        <div id="div_swf_1" class="content pad-10 <?php echo $div_status?>">
            <div>
                <div class="addnew" id="addnew">
                    <span id="buttonPlaceHolder"></span>
                </div>
                <input type="button" id="btupload" value="<?php echo L('start_upload')?>" onClick="swfu.startUpload();" />
                <div id="nameTip" class="onShow"><?php echo L('upload_up_to')?><font color="red"> <?php echo $file_upload_limit?></font> <?php echo L('attachments')?>,<?php echo L('largest')?> <font color="red"><?php echo $file_size_limit?></font></div>
                <div class="bk3"></div>

                <div class="lh24"><?php echo L('supported')?> <font style="font-family: Arial, Helvetica, sans-serif"><?php echo str_replace(array('*.',';'),array('','、'),$file_types)?></font> <?php echo L('formats')?></div><input type="checkbox" id="watermark_enable" value="1" <?php if(isset($watermark_enable) &&$watermark_enable == 1) echo 'checked'?> onclick="change_params()"> <?php echo L('watermark_enable')?>
            </div>
            <div class="bk10"></div>
            <fieldset class="blue pad-10" id="swfupload">
                <legend><?php echo L('lists')?></legend>
                <ul class="attachment-list"  id="fsUploadProgress">
                </ul>
            </fieldset>
        </div>
        <div id="div_swf_2" class="contentList pad-10 hidden">
            <div class="bk10"></div>
            <?php echo L('enter_address')?><div class="bk3"></div><input type="text" name="info[filename]" class="input-text" value=""  style="width:350px;"  onblur="addonlinefile(this)">
            <div class="bk10"></div>
        </div>
        <?php if($allowupload && $this->admin_username && $_SESSION['userid']) {?>
            <div id="div_swf_3" class="contentList pad-10 hidden">
                <ul class="attachment-list">
                    <iframe name="album-list" src="#" frameborder="false" scrolling="no" style="overflow-x:hidden;border:none" width="100%" height="345" allowtransparency="true" id="album_list"></iframe>
                </ul>
            </div>
            <div id="div_swf_4" class="contentList pad-10 hidden">
                <ul class="attachment-list">
                    <iframe name="album-dir" src="#" frameborder="false" scrolling="auto" style="overflow-x:hidden;border:none" width="100%" height="330" allowtransparency="true" id="album_dir"></iframe>
                </ul>
            </div>
        <?php }?>
        <?php if($att_not_used!='') {?>
            <div id="div_swf_5" class="contentList pad-10">
                <div class="explain-col"><?php echo L('att_not_used_desc')?></div>
                <ul class="attachment-list" id="album">
                    <?php if(is_array($att) && !empty($att)){ foreach ($att as $_v) {?>
                        <li>
                            <div class="img-wrap">
                                <a onclick="javascript:album_cancel(this,<?php echo $_v['aid']?>,'<?php echo $_v['src']?>')" href="javascript:;" class="off"  title="<?php echo $_v['filename']?>"><div class="icon"></div><img width="<?php echo $_v['width']?>"  path="<?php echo $_v['src']?>" src="<?php echo $_v['fileimg']?>" title="<?php echo $_v['filename']?>"></a>
                            </div>
                        </li>
                    <?php }}?>
                </ul>
            </div>
        <?php }?>
        <div id="att-status" class="hidden"></div>
        <div id="att-status-del" class="hidden"></div>
        <div id="att-name" class="hidden"></div>
        <!-- swf -->
    </div>
    </body>
    <script type="text/javascript">
        if ($.browser.mozilla) {
            window.onload=function(){
                if (location.href.indexOf("&rand=")<0) {
                    location.href=location.href+"&rand="+Math.random();
                }
            }
        }
        function imgWrap(obj){
            $(obj).hasClass('on') ? $(obj).removeClass("on") : $(obj).addClass("on");
        }

        function SwapTab(name,cls_show,cls_hide,cnt,cur) {
            for(i=1;i<=cnt;i++){
                if(i==cur){
                    $('#div_'+name+'_'+i).show();
                    $('#tab_'+name+'_'+i).addClass(cls_show);
                    $('#tab_'+name+'_'+i).removeClass(cls_hide);
                }else{
                    $('#div_'+name+'_'+i).hide();
                    $('#tab_'+name+'_'+i).removeClass(cls_show);
                    $('#tab_'+name+'_'+i).addClass(cls_hide);
                }
            }
        }

        function addonlinefile(obj) {
            var strs = $(obj).val() ? '|'+ $(obj).val() :'';
            $('#att-status').html(strs);
        }

        function change_params(){
            if($('#watermark_enable').attr('checked')) {
                swfu.addPostParam('watermark_enable', '1');
            } else {
                swfu.removePostParam('watermark_enable');
            }
        }
        function set_iframe(id,src){
            $("#"+id).attr("src",src);
        }
        function album_cancel(obj,id,source){
            var src = $(obj).children("img").attr("path");
            var filename = $(obj).attr('title');
            if($(obj).hasClass('on')){
                $(obj).removeClass("on");
                var imgstr = $("#att-status").html();
                var length = $("a[class='on']").children("img").length;
                var strs = filenames = '';
                $.get('index.php?m=attachment&c=attachments&a=swfupload_json_del&aid='+id+'&src='+source+'&filename='+filename);
                for(var i=0;i<length;i++){
                    strs += '|'+$("a[class='on']").children("img").eq(i).attr('path');
                    filenames += '|'+$("a[class='on']").children("img").eq(i).attr('title');
                }
                $('#att-status').html(strs);
                $('#att-status').html(filenames);
            } else {
                var num = $('#att-status').html().split('|').length;
                var file_upload_limit = '<?php echo $file_upload_limit?>';
                if(num > file_upload_limit) {alert('<?php echo L('attachment_tip1')?>'+file_upload_limit+'<?php echo L('attachment_tip2')?>'); return false;}
                $(obj).addClass("on");
                $.get('index.php?m=attachment&c=attachments&a=swfupload_json&aid='+id+'&src='+source+'&filename='+filename);
                $('#att-status').append('|'+src);
                $('#att-name').append('|'+filename);
            }
        }
    </script>
    </html>
